var http = require("http");
var url = require("url");

function start(route, handle) {
	function onRequest(request, response) {
		var postData = "";
		
		var pathname = url.parse(request.url).pathname;
		console.log("request for " + pathname + " received.");
		
		/*
		request.setEncoding("utf8");
		request.addListener("data", function(postDataChunk) {
			postData += postDataChunk;
			console.log("received post data chunk " + postDataChunk + ".");
		});
		request.addListener("end", function(){
			route(handle, pathname, response, postData);
		});
		*/
		route(handle, pathname, response, request);


		//route(handle, pathname, response);
	}
	http.createServer(onRequest).listen(8888);
	console.log("server has started.");
}

exports.start = start;

